home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
boe.pres.k12.wv.us
/
boe.pres.k12.wv.us.zip
/
boe.pres.k12.wv.us
/
Utilities
/
Xerox Workcentre 5335
/
Windows Scan
/
32-bit_x86
/
Francais
/
cpsimage.cab
/
data
/
xipProcs
/
FrameIt.proc
< prev
next >
Wrap
Text File
|
2009-03-16
|
4KB
|
138 lines
/* @FrameIt
// DESCRIPTION
Puts a simple gradient highlighted frame around an image. The default
size is 10 pixels.
General syntax:
XIPIMAGE out = FrameIt (inImg: input [, optionals] );
Optional Arguments:
size : INTEGER Frame size in pixels
light : STRING Direction of light
color : LIST Color in r,g,b to use, e.g., (0,128,200)
transparency : INTEGER Percent transparency
Light direction is from the upper left by default. You can set the
direction with "light" option. Use the following strings:
FrameIt ( light:"ul" ,...) = light direction from upper left
FrameIt ( light:"ur" ,...) = light direction from upper right
FrameIt ( light:"lr" ,...) = light direction from lower right
FrameIt ( light:"ll" ,...) = light direction from lower left
FrameIt ( light:"in" ,...) = light eminates from in the frame
FrameIt ( light:"out",...) = light eminates from outside the frame
FrameIt ( light:"top",...) = light is on top of the frame
FrameIt ( light:"bot",...) = light eminates from underneath the frame
// Example:
// Given that you already have an image "img", the following gives
// a 25 pixel wide frame, light from the top, with a redish cast.
img = FrameIt (inImg: img,
size: 25,
light: "top",
color: (200,55,55),
transparency: 50);
*/
PROCEDURE FrameIt (XIPIMAGE inImg,
INTEGER size,
STRING light,
LIST color,
INTEGER transparency)
RETURNS (XIPIMAGE out)
{
INTEGER j;
LIST gp1 = (1,0,1,0); // Set the list of sides to use, lt,rt,top,bot
LIST gp2 = (0,1,0,1); // Set the list of sides to use, lt,rt,top,bot
// If no size set
if (size == 0) size = 10;
// pull the image through
INTEGER w = inImg.imageWidth;
INTEGER h = inImg.imageHeight;
if (color) {
inImg = inImg.exec();
w = inImg.imageWidth;
h = inImg.imageHeight;
}
// Set gradient values
DOUBLE low = 32;
DOUBLE high = 200;
DOUBLE offset = (high-low) / size;
// Set the frame instances
if (light == "ur")
{ gp1 = (0,1,1,0); gp2 = (1,0,0,1); }
else if (light == "lr")
{ gp1 = (0,1,0,1); gp2 = (1,0,1,0); }
else if (light == "ll")
{ gp1 = (1,0,0,1); gp2 = (0,1,1,0); }
else if (light == "in") {
gp1 = (1,1,1,1);
for (j=0; j<size; j=j+1;)
inImg = inImg.frame (outside: 1, thick: gp1, value: (high -j * offset));
out = inImg;
}
else if (light == "top") {
gp1 = (1,1,1,1);
offset = offset * 2;
for (j=0; j<size/2; j=j+1;)
inImg = inImg.frame (outside: 1, thick: gp1, value: (low +j * offset));
if ( (size/2)*2 != size)
inImg = inImg.frame (outside: 1, thick: gp1, value: (high) );
for (j=0; j<size/2; j=j+1;)
inImg = inImg.frame (outside: 1, thick: gp1, value: (high-j * offset));
out = inImg;
}
else if (light == "bot") {
gp1 = (1,1,1,1);
offset = offset * 2;
for (j=0; j<size/2; j=j+1;)
inImg = inImg.frame (outside: 1, thick: gp1, value: (high-j * offset));
if ( (size/2)*2 != size)
inImg = inImg.frame (outside: 1, thick: gp1, value: (low) );
for (j=0; j<size/2; j=j+1;)
inImg = inImg.frame (outside: 1, thick: gp1, value: (low +j * offset));
out = inImg;
}
else if (light == "out") {
gp1 = (1,1,1,1);
for (j=0; j<size; j=j+1;)
inImg = inImg.frame (outside: 1, thick: gp1, value: (low +j * offset));
out = inImg;
}
// Default processing adds two sides at a time
if (!out)
for (j=0; j<size; j=j+1;)
inImg = inImg.frame (outside: 1, thick: gp1, value: (low +j * offset)
).frame (outside: 1, thick: gp2, value: (high -j * offset));
if (color) {
INTEGER r = color[0];
INTEGER g = color[1];
INTEGER b = color[2];
if (transparency == 0)
transparency = 128;
else
transparency = 256.0 - (transparency/100.0 * 256.0);
inImg = inImg.tfill (outside: 1,
window: (size,size,w,h),
colors: (r,g,b),
transparency: transparency);
}
// Set the output image
out = inImg;
}